<template>
  <div>
    <header>
      <h1 class="title">Vue Router</h1>
    </header>
    <content class="main">
      <nav class="nav">
        <ul class="list">
          <!-- 
            router-link 路由链接跳转：切换路由地址  
              选中的router-link会自动添加两个类名：router-link-exact-active router-link-active
                router-link-active可以修改：通过active-class="xxx"
                router-link-exact-active可以修改：exact-active-class="yyy"
            router-view 加载显示相应路由组件
           -->
          <li>
            <router-link to="/home" active-class="xxx" exact-active-class="yyy"
              >Home</router-link
            >
          </li>
          <li><router-link to="/about">About</router-link></li>
        </ul>
      </nav>
      <div class="content">
        <!-- 
          默认情况下：
            路由路由切换时：A -> B
              A组件会被卸载
              B组件走初始化流程加载
          
          加上keep-alive组件：
            路由路由切换时：A -> B
            第一次会走初始化流程加载
            不会被卸载了
         -->
        <keep-alive include="Home,About">
          <router-view sex="男" />
        </keep-alive>
      </div>
    </content>
  </div>
</template>

<script>
export default {
  name: "App",
  components: {},
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
ul {
  list-style: none;
}
a {
  text-decoration: none;
}
.title {
  text-align: center;
  margin-bottom: 20px;
}
.main {
  display: flex;
  padding: 0 20px;
}
.nav {
  flex: 1;
  background-color: pink;
}
.content {
  flex: 3;
  background-color: yellowgreen;
  padding: 10px 20px;
}
.list li {
  padding: 10px 20px;
  border-top: 1px solid #ccc;
  border-left: 1px solid #ccc;
  border-right: 1px solid #ccc;
}
.list li:last-child {
  border-bottom: 1px solid #ccc;
}
.router-link-active {
  color: #fff;
}
</style>
